package com.wn.airplane_mode.receiver;

import com.wn.airplane_mode.service.AirplaneModeOpService;
import com.wn.airplane_mode.tool.AirplaneTool;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

/**
 * @author Grant Woo
 * 开机自动启动服务*/
public class AirplaneModeOpServiceAutoStartupReceiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context context, Intent intent) {
		//Log.i("AirplaneModeOpServiceAutoStartupReceiver", "onReceive...");
		AirplaneTool tool = AirplaneTool.getInstance(context);
		//如果开机自动启动，则启动后台服务
		if(tool.isAutoStartupService()){
			//Intent service = new Intent(Tool.SERVICE_NAME);	
			Intent service = new Intent(context,AirplaneModeOpService.class);
			
			if(context.startService(service)!=null){
				//tool.setServiceRunning(true);
				Log.i("AirplaneModeOpServiceAutoStartupReceiver", "onReceive...isAutoStartupService");
			}else{
				//tool.setServiceRunning(false);
			}
		}
	
	}

}
